From 58da6b05d47da76bd8309745ae1c271b948ae900 Mon Sep 17 00:00:00 2001 From: Tyler Hall Date: Sun, 29 Jan 2017 17:55:38 -0500 Subject: [PATCH] Adjust custom target test for workspace-relative hashing Switching to workspace-relative metadata hashing means that output can change based on what is considered to be the top-level crate. This test is affected by this change, but in general hashes should be more stable than before. This test verifies that a crate will not rebuild when built as a dependency of two different crates but with the same CARGO_TARGET_DIR. This currently relies on the absolute path to the crate being the same across runs. Set an explicit workspace so the hashes will be the same when using workspace-relative hashing. Setting a workspace would cause the target dir to be the same in both invocations, defeating the intent of this test, so move the target dir between runs to verify that the contents of the target dir are not dependent on its path. --- tests/path.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/path.rs b/tests/path.rs index 16335e216..97ccac7b1 100644 --- a/tests/path.rs +++ b/tests/path.rs @@ -1,4 +1,5 @@ extern crate cargo; +#[macro_use] extern crate cargotest; extern crate hamcrest; @@ -808,6 +809,8 @@ fn custom_target_no_rebuild() { authors = [] [dependencies] a = { path = "a" } + [workspace] + members = ["a", "b"] "#) .file("src/lib.rs", "") .file("a/Cargo.toml", r#" @@ -835,9 +838,10 @@ fn custom_target_no_rebuild() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ")); + t!(fs::rename(p.root().join("target"), p.root().join("target_moved"))); assert_that(p.cargo("build") .arg("--manifest-path=b/Cargo.toml") - .env("CARGO_TARGET_DIR", "target"), + .env("CARGO_TARGET_DIR", "target_moved"), execs().with_status(0) .with_stderr("\ [COMPILING] b v0.5.0 ([..]) -- 2.30.2